﻿<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>朗读结束</title>
<meta http-equiv="pragma" content="no-cache">  
<meta http-equiv="cache-control" content="no-cache">  
<meta http-equiv="expires" content="0">  
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/d_common.css">
<link rel="stylesheet" href="css/c_five.css">
<style>
#addGC {
    position: relative;
    width: 98%;
    margin: 0 auto;
}
#addGC ul li {
    margin: 5px 0.5%;
    font-size: 14px;
    text-align: center;
}
#addGC ul li input {
    width: 145px;
    height: 25px;
    padding: 0 5px;
    line-height: 27px;
    border: 1px solid #105A93;
    border-radius: 3px;
}
.but {
	display: inline-block;
    height: 40px;
    width: 100px;
    text-align: center;
    padding: 5px;
    background: #fff;
    color: #105A93;
    line-height:40px;
    border: 1px solid #105A93;
    border-radius: 5px;
    font-size: 20px;
}
.c-phone{
	display: inline-block;
	left: 100px;
}
.but2 {
   	display: inline-block;
	width: 72px;
	height: 50px;
    background: #fff;
    color: #105A93;
    line-height: 50px;
    border: 1px solid #105A93;
    border-radius: 5px;
    margin: 0px;
    text-align: center;
    font-size: 24px;
}

</style>
</head>
<body class="bg3">
	<div id="back">
		<div class="header">
			<div class="logo">
				<a href="declaimer/first?guid=${guid}&devicecode=${devicecode}"><img
					src="img/n_logo.png" alt="">
				</a>
			</div>
		</div>

		<div class="main">
			<div class="cont clear">
				<span>	<a href="declaimer/first?guid=${guid}&devicecode=${devicecode}">
				<img src="img/close.png" alt="">
				</a>
				</span>
				<div class="cont_fl fl">
					<div id="video">
						<video src="" id="videosrc" controls="controls"> 您的浏览器不支持 video 标签。 </video>
					</div>
				</div>
				<div class="login_wx fr">
					<img
						src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${ticket }"
						alt="">
					<!--<p>扫一扫，关注公众号</p>-->
					<ol class="tipol">
						<li>本次朗读已经结束！</li>
						<li>如需要再次朗读，请扫描上图二维码重新登录！</li>
						<li>关注信昇达微信号可查看朗读记录。</li>
					</ol>
					<div id="savelubo" style="display:none;"><button style="padding:9px;font-weight:bolder;font-family:方正小标宋_GBK;font-size:20px;" onclick="saveUrl();">保存录播</button></div>
				</div>
			</div>
		</div>
	</div>
	<div id="phone" style="display:none;font-size:16px;">
		<form id="phoneInfo">
		<div id="addGC">
			<ul>
				<li><span class="c-phone">手机号码：</span> <input type="text"
					id="phoneno" name="phoneno" />
				</li>
            <li>
            	<a class="but2" onclick="set(1);">1</a>
            	<a class="but2" onclick="set(2);">2</a>
            	<a class="but2" onclick="set(3);">3</a>
            </li>
            <li>
	            <a class="but2" onclick="set(4);">4</a>
	            <a class="but2" onclick="set(5);">5</a>
	            <a class="but2" onclick="set(6);">6</a>
            	
            </li>
            <li>
            	<a class="but2" onclick="set(7);">7</a>
            	<a class="but2" onclick="set(8);">8</a>
            	<a class="but2" onclick="set(9);">9</a>
            	
            </li>
            <li>
            	<a class="but2" onclick="delall();">←</a>
            	<a class="but2" onclick="set(0);">0</a>
            	<a class="but2" onclick="delone();">D</a>
            </li>
			<li><span>是否公开你的作品供他人欣赏学习：</span> <input style="width:20px;" type="radio"
					 name="isopen" value="1" checked/>是
					 <input type="radio" style="width:20px;"
					 name="isopen" value="0"/>否
				</li>
			</ul>
		</div>
		</form>
		<p style="margin-top:12px;padding-top:1px;text-align: center;">
			<a class="but" onclick="savePhoneNo();">上传</a>
		</p>
	</div>
	<script src="js/jquery-1.9.1.js"></script>
	<script src="js/layer/layer.js"></script>
	<script>
	//加载层-风格4
	var index = layer.msg('视频正在缓存中', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false, time:100000});
		
	var localip = '${localip}';
	
	var i = 600;
	
	function Timeout(){
		if(i>0){
			i--;
			setTimeout(function(){Timeout();},1000);
		}else{
			window.location.href="<%=basePath%>declaimer/first?devicecode=${devicecode}&guid=${guid}";
		}
	}
	setTimeout(function() {getpath();}, 5000);
	function getpath() {
		$.ajax({
			type : "get",
			dataType : 'jsonp',
			jsonp : "jsoncallback",
			timeout : 5000,
			url : 'http://'
					+ localip
					+ '/classes/common/Reading.php?method=getLastVideoPath',// 请求的action路径
			error : function(XMLHttpRequest, textStatus,
					errorThrown) {
				if (XMLHttpRequest.status != 200) {
					setTimeout(function() {getpath();}, 5000);
					Timeout();
				}
			},
			success : function(data) {

			}
		});
	}
setEncoderState();
function setEncoderState(){
			$.ajax({
				type: "get",
		        dataType: 'jsonp',
		        timeout:30000,
				url :  'http://'+localip+'/classes/common/Reading.php?method=setEncoderState&channelId=1&state=5',// 请求的action路径
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					
				},
				success : function (data) {
				}
			});
		}
		var urlpath;
	//处理录播设备返回数据
	function jsoncallback(data) {
	   if(data!='OK'){
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			dataType : "json",
			url : 'declaimer/readurl?guid=${guid}&devicecode=${devicecode }&url='
					+ data,// 请求的action路径
			error : function(XMLHttpRequest, textStatus,
					errorThrown) {
				layer.msg("请求失败！");
			},
			success : function(data1) {
				if (data1=='1') {
					layer.close(index);
					$("#videosrc").attr("src","http://" + localip + data);
					urlpath = data;
					$("#savelubo").show();
				} else if (data1=='2') {
					setTimeout(function() {
						getpath();
					}, 5000);
				}else{
					layer.close(index);
					$("#videosrc").attr("src","http://" + localip + data);
				}
			}
		});
		}
	}
	var index2;
	function saveUrl(){
		index2 = layer.open({
			title : '读者手机号',
			type : 1,
			area : [ '330px', '410px' ],
			fixed : false, //不固定
			//maxmin: true,
			content : $('#phone')
		});
	}
	function savePhoneNo(){
		var phoneno = $("#phoneno").val();
		if(phoneno.length!=11){
			layer.msg("手机号格式不正确！");
		}else{
			$.ajax({
				async : false,
				cache : false,
				type : 'post',
				data : $("#phoneInfo").serialize(),
				dataType : "json",
				url : 'declaimer/saveReadInfo?guid=${guid}&devicecode=${devicecode }',// 请求的action路径
				error : function(XMLHttpRequest, textStatus,
						errorThrown) {
					layer.msg("请求失败！");
				},
				success : function(data1) {
					if (data1==true) {
						layer.msg("上传中，请等待几分钟后观看微信的推送的视频信息！");
						layer.close(index2);
						$("#savelubo").hide();
					}else{
						layer.msg("上传失败！");
					}
				}
			});
			location.href = "Wldt:http://" + localip + urlpath;
		}
		
	}
	function set(val){
		$("#phoneno").val($("#phoneno").val()+val);
	}
	function delall(){
		$("#phoneno").val('');
	}
	function delone(){
		$("#phoneno").val($("#phoneno").val().substring(0,$("#phoneno").val().length-1));
	}
	</script>
</body>

</html>